<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目基本信息')"/>
    <style>
        @media print {
            body {
                text-align: center;
            }
        }
    </style>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m"
          style="text-align: center"
          id="form-project-detail"
          th:object="${sysProject}">
        <input name="projectId" th:field="*{projectId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-4 control-label">项目名称：</label>
            <div class="col-sm-8">
                <h4>[[*{projectName}]]</h4>
            </div>

        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">项目地址：</label>
            <div class="col-sm-8">
                <h4>[[*{address}]]</h4>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">建设单位：</label>
            <div class="col-sm-8">
                <h4>[[*{projectOwner}]]</h4>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-4 control-label">施工单位：</label>
            <div class="col-sm-8">
                <h4>[[*{projectContractor}]]</h4>
            </div>
        </div>
        <div class="form-group" id="qrCode">
            <label class="col-sm-4 control-label"></label>
            <div class="col-sm-12">
                <img th:src="'data:image/png;base64,' +*{qrCode}"/>
            </div>
        </div>
    </form>
    <div class="form-group" style="text-align: center">
        <div class="col-sm-6">
            <a class="btn btn-success"
               onclick="downQrCode()">
                <i class="fa fa-plus"></i> 下载二维码
            </a>
        </div>
        <div class="col-sm-6">
            <a class="btn btn-warning"
               onclick="printQrCode()">
                <i class="fa fa-download"></i> 打印二维码
            </a>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "process/project";
    var sysProject = [[${sysProject}]];

    $("#form-project-detail").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-project-detail').serialize());
        }
    }

    function downQrCode() {
        var id = sysProject.projectId;
        window.location.href = prefix + "/downQrCode/" + id;
    }

    function printQrCode() {
        let newdocument = document.getElementById("form-project-detail");
        let newstr = newdocument.innerHTML;
        let oldstr = document.body.innerHTML;
        document.body.innerHTML = newstr;
        window.print();
        document.body.innerHTML = oldstr;
        return false;
    }
</script>
</body>
</html>